package com.typy.www.tpay.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.typy.www.tpay.R;
import com.typy.www.tpay.bean.bean.HomeBtnBean;
import com.typy.www.tpay.ui.adapter.MineGridAdapter;
import com.typy.www.tpay.ui.view.CircleImageView;
import com.typy.www.tpay.util.Logutil;
import com.zhy.android.percent.support.PercentLinearLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by 13799 on 2018/6/9.
 */

public class MineFragment extends BaseTitlebarFragment {
    @BindView(R.id.img_userHead)
    CircleImageView imgUserHead;
    @BindView(R.id.tv_userId)
    TextView tvUserId;
    @BindView(R.id.tv_xunyu)
    TextView tvXunyu;
    @BindView(R.id.ll_userInfo)
    PercentLinearLayout llUserInfo;
    @BindView(R.id.img_setting)
    ImageView imgSetting;
    Unbinder unbinder;
    @BindView(R.id.tv_yue)
    TextView tvYue;
    @BindView(R.id.tv_jifen)
    TextView tvJifen;
    GridView gvMine;
    MineGridAdapter adapter;

    @Override
    protected int getContentResId() {
        return R.layout.activity_mine;
    }

    @Override
    protected int getTitlebarResId() {
        return -1;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @Override
    protected void initView() {
        super.initView();
        initAdapter();
    }

    private void initAdapter() {
        gvMine = content.findViewById(R.id.gv_mine);
        adapter = new MineGridAdapter(getContext());
        gvMine.setAdapter(adapter);
        setList();
    }

    private void setList() {
        List<HomeBtnBean> list = new ArrayList<>();
        list.add(HomeBtnBean.getBean("转出", R.drawable.shouye_zhuanchu));
        list.add(HomeBtnBean.getBean("转入",  R.drawable.shouye_zhuanru));
        list.add(HomeBtnBean.getBean("买入",  R.drawable.shouye_mairu));
        list.add(HomeBtnBean.getBean("卖出",  R.drawable.shouye_maichu));
        list.add(HomeBtnBean.getBean("数字资产",  R.drawable.shouye_shuzizichan));
        list.add(HomeBtnBean.getBean("商场",  R.drawable.shouye_shuzizichan));
        list.add(HomeBtnBean.getBean("兑换积分",  R.drawable.shouye_duihuanjifen));
        list.add(HomeBtnBean.getBean("设置",  R.drawable.shouye_shezhi));
        list.add(HomeBtnBean.getBean("分享",  R.drawable.shouye_fenxiang));
        adapter.setList(list);
        adapter.notifyDataSetChanged();
    }


    @OnClick({R.id.ll_userInfo, R.id.img_setting})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_userInfo:
                break;
            case R.id.img_setting:
                break;
        }
    }
}
